VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{753FEE6F-A545-4EAA-AAC8-87512ED29F21}#3.0#0"; "ccrpDtp6.ocx"
Object = "{8D650141-6025-11D1-BC40-0000C042AEC0}#3.0#0"; "ssdw3b32.ocx"
Begin VB.Form frmCanceladosProfesional 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Turnos Cancelados por Profesional"
   ClientHeight    =   7230
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9990
   Icon            =   "frmCanceladosProfesional.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7230
   ScaleWidth      =   9990
   Begin VB.CommandButton cmdImprimir 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      Caption         =   "Imprimir"
      Enabled         =   0   'False
      Height          =   390
      Left            =   8520
      MaskColor       =   &H00FFFFFF&
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   1200
      Width           =   1140
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Fecha"
      Height          =   1575
      Left            =   5520
      TabIndex        =   11
      Top             =   360
      Width           =   2535
      Begin VB.ComboBox cmbFec 
         Height          =   315
         ItemData        =   "frmCanceladosProfesional.frx":08CA
         Left            =   840
         List            =   "frmCanceladosProfesional.frx":08D4
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   360
         Width           =   1575
      End
      Begin CCRPDTP6.ccrpDtp cmbFecDes 
         Height          =   315
         Left            =   840
         TabIndex        =   3
         Top             =   720
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   556
         CustomFormat    =   "dd/MM/yyyy"
         Min             =   36526
         Max             =   219512
         CCRPVer         =   1
         Var             =   "frmCanceladosProfesional.frx":08F3
         XD              =   "frmCanceladosProfesional.frx":0927
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "04/07/2012"
      End
      Begin CCRPDTP6.ccrpDtp cmbFecHas 
         Height          =   315
         Left            =   840
         TabIndex        =   4
         Top             =   1080
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   556
         CustomFormat    =   "dd/MM/yyyy"
         Min             =   36526
         Max             =   219512
         CCRPVer         =   1
         Var             =   "frmCanceladosProfesional.frx":0983
         XD              =   "frmCanceladosProfesional.frx":09B7
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "04/07/2012"
      End
      Begin VB.Label Label5 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Por:"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label4 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Desde:"
         Height          =   255
         Left            =   240
         TabIndex        =   13
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label3 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Hasta:"
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   1080
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Profesional"
      Height          =   1575
      Left            =   120
      TabIndex        =   8
      Top             =   360
      Width           =   5295
      Begin VB.ComboBox cmbProfDes 
         Height          =   315
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   480
         Width           =   5055
      End
      Begin VB.ComboBox cmbProfHas 
         Height          =   315
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   1080
         Width           =   5055
      End
      Begin VB.Label Label1 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Desde:"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   240
         Width           =   615
      End
      Begin VB.Label Label2 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Hasta:"
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   840
         Width           =   615
      End
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2280
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   11
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":0A13
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":0FAD
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":1547
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":1AE1
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":207B
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":2615
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":2BAF
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":3149
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":36E3
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":3C7D
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCanceladosProfesional.frx":4217
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   360
      Left            =   0
      TabIndex        =   7
      Top             =   0
      Width           =   9990
      _ExtentX        =   17621
      _ExtentY        =   635
      ButtonWidth     =   609
      ButtonHeight    =   582
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   6
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "Aceptar"
            Object.ToolTipText     =   "Aceptar (F5)"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Enabled         =   0   'False
            Key             =   "Cancelar"
            Object.ToolTipText     =   "Cancelar (F8)"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "Salir"
            Object.ToolTipText     =   "Salir (Esc)"
            ImageIndex      =   11
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
   Begin SSDataWidgets_B.SSDBGrid Grilla 
      Height          =   5055
      Left            =   120
      TabIndex        =   6
      Top             =   2040
      Width           =   9735
      _Version        =   196616
      DataMode        =   2
      Col.Count       =   7
      BevelColorFace  =   16777215
      AllowUpdate     =   0   'False
      RowSelectionStyle=   2
      AllowRowSizing  =   0   'False
      AllowGroupSizing=   0   'False
      AllowGroupMoving=   0   'False
      AllowGroupSwapping=   0   'False
      AllowGroupShrinking=   0   'False
      AllowDragDrop   =   0   'False
      SelectTypeCol   =   0
      SelectTypeRow   =   1
      BackColorEven   =   12648447
      BackColorOdd    =   12640511
      RowHeight       =   423
      Columns.Count   =   7
      Columns(0).Width=   4048
      Columns(0).Caption=   "Profesional"
      Columns(0).Name =   "Profesional"
      Columns(0).CaptionAlignment=   2
      Columns(0).DataField=   "Column 0"
      Columns(0).DataType=   8
      Columns(0).FieldLen=   256
      Columns(1).Width=   2117
      Columns(1).Caption=   "Fecha Turnos"
      Columns(1).Name =   "Fecha Turnos"
      Columns(1).Alignment=   2
      Columns(1).CaptionAlignment=   2
      Columns(1).DataField=   "Column 1"
      Columns(1).DataType=   8
      Columns(1).FieldLen=   256
      Columns(2).Width=   1931
      Columns(2).Caption=   "Cant. Turnos"
      Columns(2).Name =   "Cant. Turnos"
      Columns(2).Alignment=   2
      Columns(2).CaptionAlignment=   2
      Columns(2).DataField=   "Column 2"
      Columns(2).DataType=   8
      Columns(2).FieldLen=   256
      Columns(3).Width=   2117
      Columns(3).Caption=   "Fecha Aviso"
      Columns(3).Name =   "Fecha Aviso"
      Columns(3).Alignment=   2
      Columns(3).CaptionAlignment=   2
      Columns(3).DataField=   "Column 3"
      Columns(3).DataType=   8
      Columns(3).FieldLen=   256
      Columns(4).Width=   1773
      Columns(4).Caption=   "Hora Aviso"
      Columns(4).Name =   "Hora Aviso"
      Columns(4).Alignment=   2
      Columns(4).CaptionAlignment=   2
      Columns(4).DataField=   "Column 4"
      Columns(4).DataType=   8
      Columns(4).FieldLen=   256
      Columns(5).Width=   4048
      Columns(5).Caption=   "Observacion"
      Columns(5).Name =   "Observacion"
      Columns(5).CaptionAlignment=   2
      Columns(5).DataField=   "Column 5"
      Columns(5).DataType=   8
      Columns(5).FieldLen=   256
      Columns(6).Width=   3200
      Columns(6).Caption=   "Usuario"
      Columns(6).Name =   "Usuario"
      Columns(6).CaptionAlignment=   2
      Columns(6).DataField=   "Column 6"
      Columns(6).DataType=   8
      Columns(6).FieldLen=   256
      _ExtentX        =   17171
      _ExtentY        =   8916
      _StockProps     =   79
      Caption         =   "Turnos"
      BackColor       =   -2147483643
      BeginProperty PageFooterFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty PageHeaderFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "frmCanceladosProfesional"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdImprimir_Click()

Imprimir True

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Select Case Button.Key

    Case "Salir"
        Unload Me
    
    Case "Aceptar"
        If Control Then Exit Sub
        Imprimir False
        
    Case "Cancelar"
        inHabilitar
       
End Select

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
    Case 27 'Escape "Salir"
        If Toolbar1.Buttons(5).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(5)
        
    Case 112 'F1 "Ayuta"
        frmPrincipal.manual_Click
        
    Case 116 'F5 "Aceptar"
        If Toolbar1.Buttons(2).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(2)
    
    Case 119 'F8 "Cancelar"
        If Toolbar1.Buttons(3).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(3)
        
End Select

End Sub

Private Sub Form_Load()

Dim con As New ConBaseDatos

Abrir Me

con.AbrirRegistros "select profesional,apellido + ', ' + nombre + ' - ' + 'Mat.Prof.: ' + matricula_profesional as nombre from profesionales where activo = 1 order by apellido,nombre", Consulta
Do While Not con.Registros.EOF
    cmbProfDes.AddItem DesEditar(con.Registros("nombre"))
    cmbProfDes.ItemData(cmbProfDes.NewIndex) = CInt(con.Registros("profesional"))
    cmbProfHas.AddItem DesEditar(con.Registros("nombre"))
    cmbProfHas.ItemData(cmbProfHas.NewIndex) = CInt(con.Registros("profesional"))
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros
If cmbProfDes.ListCount > 0 Then cmbProfDes.ListIndex = 0
If cmbProfHas.ListCount > 0 Then cmbProfHas.ListIndex = cmbProfHas.ListCount - 1

End Sub

Private Sub Form_Unload(Cancel As Integer)

If Not Toolbar1.Buttons(5).Enabled Then Cancel = True

End Sub

Private Sub cmbProfDes_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbProfDes_LostFocus()

cmbProfDes.BackColor = &H80000005

End Sub

Private Sub cmbProfDes_GotFocus()

cmbProfDes.BackColor = &HFFFFC0

End Sub

Private Sub cmbProfHas_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbProfHas_LostFocus()

cmbProfHas.BackColor = &H80000005

End Sub

Private Sub cmbProfHas_GotFocus()

cmbProfHas.BackColor = &HFFFFC0

End Sub

Private Sub cmbFec_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbFec_LostFocus()

cmbFec.BackColor = &H80000005

End Sub

Private Sub cmbFec_GotFocus()

cmbFec.BackColor = &HFFFFC0

End Sub

Private Sub cmbFecDes_GotFocus()

cmbFecDes.CalBackColor = &HFFFFC0

End Sub

Private Sub cmbFecDes_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbFecDes_LostFocus()

cmbFecDes.CalBackColor = &H80000005

End Sub

Private Sub cmbFecHas_GotFocus()

cmbFecHas.CalBackColor = &HFFFFC0

End Sub

Private Sub cmbFecHas_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbFecHas_LostFocus()

cmbFecHas.CalBackColor = &H80000005

End Sub

Private Sub inHabilitar()

Toolbar1.Buttons.Item(2).Enabled = True
Toolbar1.Buttons.Item(3).Enabled = False
cmdImprimir.Enabled = False
cmbFecDes.Enabled = True
cmbFecHas.Enabled = True
cmbFecDes.Value = Fecha_Server
cmbFecHas.Value = Fecha_Server
cmbFec.ListIndex = -1
cmbFec.Enabled = True
cmbProfDes.ListIndex = -1
cmbProfDes.Enabled = True
cmbProfHas.ListIndex = -1
cmbProfHas.Enabled = True
Grilla.RemoveAll
If cmbProfDes.ListCount > 0 Then cmbProfDes.ListIndex = 0
If cmbProfHas.ListCount > 0 Then cmbProfHas.ListIndex = cmbProfHas.ListCount - 1

End Sub

Private Sub Habilitar()

Toolbar1.Buttons.Item(2).Enabled = False
Toolbar1.Buttons.Item(3).Enabled = True
cmdImprimir.Enabled = True
cmbFecDes.Enabled = False
cmbFecHas.Enabled = False
cmbFec.Enabled = False
cmbProfDes.Enabled = False
cmbProfHas.Enabled = False

End Sub

Private Function Control() As Boolean

Control = False

If cmbProfDes.ListIndex = -1 Then
    MsgBox "Seleccione profesional desde", vbCritical, "Error de datos"
    Control = True
    cmbProfDes.SetFocus
    
ElseIf cmbProfHas.ListIndex = -1 Then
    MsgBox "Seleccione profesional hasde", vbCritical, "Error de datos"
    Control = True
    cmbProfHas.SetFocus
    
ElseIf cmbFec.ListIndex = -1 Then
    MsgBox "Seleccione fecha por", vbCritical, "Error de datos"
    Control = True
    cmbFec.SetFocus

ElseIf DateDiff("d", cmbFecDes.Value, cmbFecHas.Value) < 0 Then
    MsgBox "Fecha hasta no puede ser menor a desde", vbCritical, "Error de datos"
    Control = True
    cmbFecHas.SetFocus
    
End If

End Function

Public Sub Imprimir(Imprime As Boolean)

Dim cWhere As String, cSql As String, dato As String, cDato As String
Dim InfExel As Object, i As Integer, Linea As Integer, con As New ConBaseDatos

Select Case cmbFec.ItemData(cmbFec.ListIndex)
    Case 0 'fecha turnos
        cWhere = "and c.fecha_turno between '" & cmbFecDes.Value & "' and '" & cmbFecHas.Value & "'"
    Case 1 'fecha aviso
        cWhere = "and c.fecha_aviso between '" & cmbFecDes.Value & "' and '" & cmbFecHas.Value + 1 & "'"
End Select

cSql = "select p.apellido + ', ' + p.nombre + ' - ' + 'Mat.Prof.: ' + p.matricula_profesional as profesional,c.fecha_turno,count(t.cancelacion_turno_profesional) as turnos,c.fecha_aviso,c.observacion,u.nombre as usuario from Cancelacion_turnos_profesional c left join profesionales p on p.profesional=c.profesional inner join turnos t on t.cancelacion_turno_profesional=c.cancelacion_turno_profesional left join usuarios u on u.usuario=c.usuario where c.activo=1 and p.apellido + ', ' + p.nombre + ' - ' + 'Mat.Prof.: ' + p.matricula_profesional between '" & cmbProfDes.Text & "' and '" & cmbProfHas.Text & "' "
cSql = cSql + cWhere + " group by p.apellido + ', ' + p.nombre + ' - ' + 'Mat.Prof.: ' + p.matricula_profesional,c.fecha_turno,c.fecha_aviso,c.observacion,u.nombre order by 2 desc,1 asc"
con.AbrirRegistros cSql, Consulta

Grilla.RemoveAll
If con.Registros.EOF Then
    MsgBox "No hay Turnos en la seleccion actual", vbExclamation, "Turnos"
    inHabilitar
    Exit Sub
End If

'cargo la grilla
Grilla.Redraw = False
Do While Not con.Registros.EOF
    dato = ""
    For i = 0 To Grilla.Cols - 1
        If i = 3 Then
            cDato = IIf(IsNull(con.Registros(3)), "", Format(con.Registros(3), "dd/mm/yyyy"))
        ElseIf i = 4 Then
            cDato = IIf(IsNull(con.Registros(3)), "", Format(con.Registros(3), "Hh:Nn"))
        ElseIf i = 5 Then
            cDato = IIf(IsNull(con.Registros(4)), "", con.Registros(4))
        ElseIf i = 6 Then
            cDato = IIf(IsNull(con.Registros(5)), "", con.Registros(5))
        Else
            cDato = IIf(IsNull(con.Registros(i)), "", con.Registros(i))
        End If
        dato = dato & DesEditar(cDato) & vbTab
        DoEvents
    Next i
    Grilla.AddItem dato
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros

Grilla.Redraw = True


'si imprime
If Not Imprime Then
    Habilitar
    Exit Sub
End If

If Not ExisteExcel Then
    MsgBox "Debe estar instalado MS Excel", vbCritical, "Operacion cancelada"
    Exit Sub
End If

Set InfExel = CreateObject("Excel.application")

'Agrega un nuevo Libro
InfExel.Workbooks.Add

'todas las celdas tipo texto
InfExel.Cells.Select
InfExel.Selection.NumberFormat = "@"

'hace que excel se vea
'InfExel.Visible = True

'cabecera
InfExel.Cells(2, 3).Formula = "INFORME TURNOS CANCELADOS POR PROFESIONAL"
InfExel.Cells(2, 3).Font.Size = 12

InfExel.Cells(3, 6).Formula = "Fecha:"
InfExel.Cells(3, 6).HorizontalAlignment = -4152
InfExel.Cells(3, 7).Formula = Format(Fecha_Server, "dd/mm/yyyy")
InfExel.Cells(3, 7).HorizontalAlignment = -4131

InfExel.Cells(5, 2).Formula = "Prof. Desde:"
InfExel.Cells(5, 2).HorizontalAlignment = -4152
InfExel.Cells(5, 3).Formula = cmbProfDes.Text
InfExel.Cells(5, 3).HorizontalAlignment = -4131

InfExel.Cells(6, 2).Formula = "Prof. Hasta:"
InfExel.Cells(6, 2).HorizontalAlignment = -4152
InfExel.Cells(6, 3).Formula = cmbProfHas.Text
InfExel.Cells(6, 3).HorizontalAlignment = -4131

InfExel.Cells(7, 2).Formula = "Por:"
InfExel.Cells(7, 2).HorizontalAlignment = -4152
InfExel.Cells(7, 3).Formula = cmbFec.Text
InfExel.Cells(7, 3).HorizontalAlignment = -4131

InfExel.Cells(7, 5).Formula = "Desde:"
InfExel.Cells(7, 5).HorizontalAlignment = -4152
InfExel.Cells(7, 6).Formula = Format(cmbFecDes.Value, "dd/mm/yyyy")
InfExel.Cells(7, 6).HorizontalAlignment = -4131

InfExel.Cells(7, 7).Formula = "Hasta:"
InfExel.Cells(7, 7).HorizontalAlignment = -4152
InfExel.Cells(7, 8).Formula = Format(cmbFecHas.Value, "dd/mm/yyyy")
InfExel.Cells(7, 8).HorizontalAlignment = -4131


'columnas
InfExel.Cells(9, 2).Formula = "Profesional"
InfExel.Cells(9, 5).Formula = "Fecha Turnos"
InfExel.Cells(9, 6).Formula = "Cant. Turnos"
InfExel.Cells(9, 7).Formula = "Fecha Aviso"
InfExel.Cells(9, 8).Formula = "Hora Aviso"
InfExel.Cells(9, 9).Formula = "Observacion"

InfExel.Range("B9:I9").Select
InfExel.Selection.Font.Bold = True
InfExel.Selection.HorizontalAlignment = -4108

'ancho columnas
InfExel.Columns("E:E").Select
InfExel.Selection.ColumnWidth = 12
InfExel.Columns("F:F").Select
InfExel.Selection.ColumnWidth = 12
InfExel.Columns("G:G").Select
InfExel.Selection.ColumnWidth = 12
InfExel.Columns("H:H").Select
InfExel.Selection.ColumnWidth = 12

'detalle
Grilla.Redraw = False
Linea = 10
Grilla.MoveFirst
For i = 0 To Grilla.Rows - 1
    InfExel.Cells(Linea, 2).Formula = Grilla.Columns(0).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 2).HorizontalAlignment = -4131
    
    InfExel.Cells(Linea, 5).Formula = Grilla.Columns(1).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 5).HorizontalAlignment = -4108
    
    InfExel.Cells(Linea, 6).Formula = Grilla.Columns(2).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 6).HorizontalAlignment = -4108
    
    InfExel.Cells(Linea, 7).Formula = Grilla.Columns(3).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 7).HorizontalAlignment = -4108
    
    InfExel.Cells(Linea, 8).Formula = Grilla.Columns(4).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 8).HorizontalAlignment = -4108
    
    InfExel.Cells(Linea, 9).Formula = Grilla.Columns(5).CellText(Grilla.Bookmark)
    InfExel.Cells(Linea, 9).HorizontalAlignment = -4131
       
    Grilla.MoveNext
    Linea = Linea + 1
    DoEvents
Next i
Grilla.MoveFirst
Grilla.Redraw = True

InfExel.Range("A1").Select

'margenes a cero
InfExel.ActiveSheet.PageSetup.LeftMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.RightMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.TopMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.BottomMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.HeaderMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.FooterMargin = InfExel.Application.InchesToPoints(0)
InfExel.ActiveSheet.PageSetup.Orientation = 2

'configuracion de encabezado y pie
With InfExel.ActiveSheet.PageSetup
    .PrintTitleRows = "$1:$9"
    .CenterFooter = "Hoja &P de &N"
End With

'imprimo el excel directo a la impresora predeterminada
'InfExel.ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

'imprimo el excel en la impresora seleccionada
Load frmImpresora
frmImpresora.Show 1
If ImpresoraSeleccionada <> "" Then
    InfExel.ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
    ImpresoraSeleccionada, Collate:=True
End If

'para que no pregunte si se quiere guardar los cambios
InfExel.ActiveWorkbook.Saved = True

'cierro el excel
InfExel.Workbooks.Close
InfExel.Quit

Set InfExel = Nothing

End Sub
